using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Xml.Serialization;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using System.Globalization;
using Barbar.MapReport.Common;
using Barbar.MapReport.Common.Drawing;
using System.Runtime.Serialization;

namespace Barbar.MapReport.HtmlRender.Operations.Legends {
  [Serializable]
  internal class LegendRangeList : LinkedList<LegendRange> {
    public LegendRangeList() {
    }

    protected LegendRangeList(SerializationInfo info, StreamingContext context)
      : base(info, context) {
    }
    
    public Color GetColor(decimal value) {
      if (Count == 1)
        return First.Value.Color;
      foreach (LegendRange entry in this) {
        if (entry.From <= value && entry.To >= value)
          return entry.Color;
      }
      throw new MapReportException("Value was not found in any range.");
    }
  }
}

